const labelService = require("../service/label.service")

class LabelController {
  async create(ctx, next) {
    // 1. 获取标签
    const { name } = ctx.request.body
    // 2. 通过数据库存储 name
    const res = await labelService.create(name)

    ctx.body = {
      code: 0,
      message: "创建标签成功",
      data: res,
    }
  }

  async list(ctx, next) {
    const { limit, offset } = ctx.query
    // 2. 到数据库中查询
    const res = await labelService.list(limit, offset)

    ctx.body = {
      code: 0,
      message: "查询标签成功",
      data: res,
    }
  }
}

module.exports = new LabelController()
